package cn.anycase.demo.base;

import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.impl.DefaultMapperFactory;

import java.io.Serializable;
import java.util.List;

/**
 * @program: stanlogy-sample
 * @description: bean属性复制类
 * @author: lmh
 * @create: 2022-09-21 23:09
 **/
public class SampleBeanCopyUtils implements Serializable{
    public static final MapperFacade MAPPER_FACADE;

    static {
        MAPPER_FACADE = new DefaultMapperFactory.Builder().build().getMapperFacade();
    }

    public static <S, D> D map(S source, Class<D> destinationClass) {
        return MAPPER_FACADE.map(source, destinationClass);
    }

    public static <S, D> void map(S source, D destination) {
        MAPPER_FACADE.map(source, destination);
    }

    public static  <S, D> List<D> mapAsList(Iterable<S> source, Class<D> destinationClass){
        return MAPPER_FACADE.mapAsList(source,destinationClass);
    }
}
